#include "DeclareFile.h"
#include"tools.h"
#include<easyx.h>
#include<time.h>
//渲染人物

//切换播放上下左右的图片
#define DownattackImg 1
#define Downmove  2
#define LeftattackImg 3
#define Leftmove 4
#define RightattackImg 5
#define Rightmove 6
#define UpattackImg 7
#define Upmove 8

void ShowHero() {
    int frames1 = 6;//图片动作1
    int frames2 = 9;//图片动作2
    static int index = 8;//播放的图片下标1-8
    
    int imgWidth;//图片宽度
    int imgHeight;//图片高度
    int flag = 8;//切换图片
    int speed1 = 200;
    int speed2 = 300;
    switch (HeroShowIndex)
    {
    case 1:
        imgWidth = 125;
        imgHeight = 100;
        putimage(imgX, imgY, imgWidth, imgHeight, &DownAttackImg, index * imgWidth + 15, 0);
        index = (clock() / speed1) % frames1;
        ControlAttack1--;
		ControlAttack2--;
		ControlAttack3--;
        ControlAttack4--;
        ControlValOne--;
        break;
    case 2:
        imgWidth = 62;
        imgHeight = 300;
        putimage(imgX, imgY, imgWidth, imgHeight, &DownImg, index * imgWidth + 3, 0);
        index = (clock() / speed2) % frames2;
        ControlValOne--;
		ControlAttack1 = 0;
		ControlAttack2 = 0;
		ControlAttack3 = 0;
		ControlAttack4 = 0;
        break;
    case 3:
        imgWidth = 125;
        imgHeight = 300;
        putimage(imgX, imgY, imgWidth, imgHeight, &LeftAttackImg, index * imgWidth + 15, 0);
        index = (clock() / speed1) % frames1;
        ControlAttack1--;
        ControlAttack2--;
        ControlAttack3--;
        ControlAttack4--;
        ControlValOne--;
        break;
    case 4:
        imgWidth = 64;
        imgHeight = 300;
        putimage(imgX, imgY, imgWidth, imgHeight, &LeftImg, index * imgWidth - 1.3, 0);
        index = (clock() / speed2) % frames2;
        ControlValOne--;
		ControlAttack1 = 0;
		ControlAttack2 = 0;
		ControlAttack3 = 0;
		ControlAttack4 = 0;
        break;
    case 5:
        imgWidth = 125;
        imgHeight = 100;
        putimage(imgX, imgY, imgWidth, imgHeight, &RightAttackImg, index * imgWidth + 15, 0);
        index = (clock() / speed1 + 100) % frames1;
        ControlAttack1--;
        ControlAttack2--;
        ControlAttack3--;
        ControlAttack4--;
        ControlValOne--;
        break;
    case 6:
        imgWidth = 63;
        imgHeight = 300;
        putimage(imgX, imgY, imgWidth, imgHeight, &RightImg, index * imgWidth + 2, 0);
        index = (clock() / speed2) % frames2;
        ControlValOne--;
		ControlAttack1 = 0;
		ControlAttack2 = 0;
		ControlAttack3 = 0;
		ControlAttack4 = 0;
        break;
    case 7:
        imgWidth = 125;
        imgHeight = 100;
        putimage(imgX, imgY, imgWidth, imgHeight, &UpAttackImg, index * imgWidth + 15, 0);
        index = (clock() / speed1) % frames1;
        ControlAttack1--;
        ControlAttack2--;
        ControlAttack3--;
        ControlAttack4--;
        ControlValOne--;
        break;
    case 8:
        imgWidth = 64;
        imgHeight = 300;
        putimage(imgX, imgY, imgWidth, imgHeight, &UpImg, index * imgWidth, 0);
        index = (clock() / speed2) % frames2;
        ControlValOne--;
		ControlAttack1 = 0;
		ControlAttack2 = 0;
		ControlAttack3 = 0;
		ControlAttack4 = 0;
        break;
    }
}